package com.kyrie.vo;

/***
 * 描述: 接口通用返回VO
 *
 * @author wuxiang
 * @date 2020-04-06 16:29:30
 */
public class ResponseBean<T> {

    private String resultCode;

    private String resultMsg;

    private T result;

    private ResponseBean (T result, String resultCode, String resultMsg) {
        this.result = result;
        this.resultCode = resultCode;
        this.resultMsg = resultMsg;
    }

    /***
     * 参数校验失败的回调方法
     * @param result 返回数据vo
     * @param resultCode 返回resultCode
     * @param resultMsg 返回resultMsg
     * @return
     */
    public static <T> ResponseBean<T> notValid (T result, String resultCode, String resultMsg) {
        return new ResponseBean<T>(result, resultCode, resultMsg);
    }

    /***
     * 数据库异常的回调方法
     * @param result 返回数据vo
     * @param resultCode 返回resultCode
     * @param resultMsg 返回resultMsg
     * @return
     */
    public static <T> ResponseBean<T> exception (T result, String resultCode, String resultMsg) {
        return new ResponseBean<T>(result, resultCode, resultMsg);
    }

    /***
     * 成功的回调方法
     * @param result 返回数据vo
     * @param resultCode 返回resultCode
     * @param resultMsg 返回resultMsg
     * @return
     */
    public static <T> ResponseBean<T> success (T result, String resultCode, String resultMsg) {
        return new ResponseBean<T>(result, resultCode, resultMsg);
    }

    /***
     * 失败的回调方法
     * @param result 返回数据vo
     * @param resultCode 返回resultCode
     * @param resultMsg 返回resultMsg
     * @return
     */
    public static <T> ResponseBean<T> fail (T result, String resultCode, String resultMsg) {
        return new ResponseBean<T>(result, resultCode, resultMsg);
    }

    public String getResultCode() {
        return resultCode;
    }

    public void setResultCode(String resultCode) {
        this.resultCode = resultCode;
    }

    public String getResultMsg() {
        return resultMsg;
    }

    public void setResultMsg(String resultMsg) {
        this.resultMsg = resultMsg;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }
}
